﻿//--------------------------------------------------------------------------------
// This file is a "Sample" as part of the MICROSOFT SDK SAMPLES FOR SHAREPOINT
// PRODUCTS AND TECHNOLOGIES
//
// (c) 2008 Microsoft Corporation.  All rights reserved.  
//
// This source code is intended only as a supplement to Microsoft
// Development Tools and/or on-line documentation.  See these other
// materials for detailed information regarding Microsoft code samples.
// 
// THIS CODE AND INFORMATION ARE PROVIDED AS IS WITHOUT WARRANTY OF ANY
// KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
// PARTICULAR PURPOSE.
//--------------------------------------------------------------------------------
// File modified to meet StyleCop's guidelines
//--------------------------------------------------------------------------------
using System;
using System.Diagnostics.CodeAnalysis;

[module: SuppressMessage("Microsoft.Naming", "CA1712:DoNotPrefixEnumValuesWithTypeName", Scope = "type", Target = "SPDisposeCheck.SPDisposeCheckID", Justification = "All SPDispose messages are tied to these IDs")]
namespace SPDisposeCheck
{
    /// <summary>
    /// List of all possible warnings from SPDisposeCheck
    /// </summary>
    [SuppressMessage("Microsoft.StyleCop.CSharp.DocumentationRules", "SA1602:EnumerationItemsMustBeDocumented", Justification = "Describing each value is not useful here.")]
    public enum SPDisposeCheckID
    {
        // SPDisposeCheckIDs.
        SPDisposeCheckID_000 = 0,   // UNDEFINED
        SPDisposeCheckID_100 = 100, // Microsoft.SharePoint.SPList.BreakRoleInheritance() method
        SPDisposeCheckID_110 = 110, // Microsoft.SharePoint.SPSite new() operator
        SPDisposeCheckID_120 = 120, // Microsoft.SharePoint.SPSite.OpenWeb()
        SPDisposeCheckID_130 = 130, // Microsoft.SharePoint.SPSite.AllWebs[] indexer
        SPDisposeCheckID_140 = 140, // Microsoft.SharePoint.SPSite.RootWeb, LockIssue, Owner, and SecondaryContact properties
        SPDisposeCheckID_150 = 150, // Microsoft.SharePoint.SPSite.AllWebs.Add() method
        SPDisposeCheckID_160 = 160, // Microsoft.SharePoint.SPWeb.GetLimitedWebPartManager() method
        SPDisposeCheckID_170 = 170, // Microsoft.SharePoint.SPWeb.ParentWeb property
        SPDisposeCheckID_180 = 180, // Microsoft.SharePoint.SPWeb.Webs property
        SPDisposeCheckID_190 = 190, // Microsoft.SharePoint.SPWeb.Webs.Add() method
        SPDisposeCheckID_200 = 200, // Microsoft.SharePoint.SPWebCollection.Add() method 
        SPDisposeCheckID_210 = 210, // Microsoft.SharePoint.WebControls.SPControl GetContextSite() and GetContextWeb() methods
        SPDisposeCheckID_220 = 220, // Microsoft.SharePoint.SPContext Current.Site / SPContext.Site and SPContext.Current.Web / SPContext.Web properties
        SPDisposeCheckID_230 = 230, // Microsoft.SharePoint.Administration.SPSiteCollection[] indexer
        SPDisposeCheckID_240 = 240, // Microsoft.SharePoint.Administration.Add() method
        SPDisposeCheckID_300 = 300, // Microsoft.SharePoint.Publishing.GetPublishingWebs() method
        SPDisposeCheckID_310 = 310, // Microsoft.SharePoint.Publishing.PublishingWebCollection.Add() method
        SPDisposeCheckID_320 = 320, // Microsoft.SharePoint.Publishing.PublishingWeb.GetVariation() method 
        SPDisposeCheckID_400 = 400, // Microsoft.Office.Server.UserProfiles.PersonalSite property 
        SPDisposeCheckID_500 = 500, // Microsoft.SharePoint.Portal.SiteData.AreaManager.GetArea() method

        // Added from post on Roger Lamb's blog on 13 Dec 2010
        SPDisposeCheckID_600 = 600, // DO NOT DISPOSE: SPListEventProperties.Web
        SPDisposeCheckID_605 = 605, // DO NOT DISPOSE: SPWebEventProperties.Web
        SPDisposeCheckID_610 = 610, // DO NOT DISPOSE: SPItemEventProperties.Web
        SPDisposeCheckID_615 = 615, // DO NOT DISPOSE: SPItemEventProperties.ListItem.Web 
        SPDisposeCheckID_620 = 620, // DO NOT DISPOSE: SPItemEventProperties.Web.Site
        SPDisposeCheckID_625 = 625, // DO NOT DISPOSE: SPItemEventProperties.ListItem.Web.Site
        SPDisposeCheckID_630 = 630, // DO NOT DISPOSE: SPFeatureReceiverProperties.Feature.Parent               
        SPDisposeCheckID_635 = 635, // DO NOT DISPOSE: SPList.ParentWeb & SPListEventProperties.List.Web
        SPDisposeCheckID_640 = 640, // DO NOT DISPOSE: SPWeb.ParentWeb
        SPDisposeCheckID_645 = 645, // DO NOT DISPOSE: SPContext.Site & SPContext.Current.Site
        SPDisposeCheckID_650 = 650, // DO NOT DISPOSE: SPContext.Web & SPContext.Current.Web
        SPDisposeCheckID_655 = 655, // DO NOT DISPOSE: SPSite.RootWeb (Covers -v1 SPSite.LockIssue, SPSite.Owner, SPSite.SecondaryContact checks)
        SPDisposeCheckID_660 = 660, // DO NOT DISPOSE: SPControl.GetContextWeb(..)
        SPDisposeCheckID_665 = 665, // DO NOT DISPOSE: SPControl.GetContextSite(..)
        SPDisposeCheckID_670 = 670, // DO NOT DISPOSE: Microsoft.SharePoint.Administration.SPSiteAdministration.OpenWeb() + 2010
        SPDisposeCheckID_700 = 700, // Microsoft.SharePoint.SPItemEventProperties.OpenWeb() on Sharepoint 2010

        SPDisposeCheckID_999 = 999  // All
    }

    /// <summary>
    /// Attribute definition for SPDisposeCheckIgnore
    /// Used to suppress warnings from SPDisposeCheck tool
    /// </summary>
    [AttributeUsage(AttributeTargets.Method | AttributeTargets.Assembly, Inherited = false, AllowMultiple = true)]
    [CLSCompliant(false)]
    public sealed class SPDisposeCheckIgnoreAttribute : Attribute
    {
        private SPDisposeCheckID _id;
        private string _reason;

        /// <summary>
        /// Standard Attribute constructor
        /// </summary>
        /// <param name="id">Message ID</param>
        /// <param name="reason">Reason for the suppression</param>
        public SPDisposeCheckIgnoreAttribute(SPDisposeCheckID id, string reason)
        {
            this._id = id;
            this._reason = reason;
        }

        /// <summary>
        /// Id of the warning to suppress
        /// </summary>
        public SPDisposeCheckID Id
        {
            get { return this._id; }
        }

        /// <summary>
        /// Reason for suppression
        /// </summary>
        public string Reason
        {
            get { return this._reason; }
        }
    }
}